package com.neusoft.wangrisheng.weektest;

import java.util.Scanner;
import java.util.regex.Pattern;

public class Jisuanqi extends Calculator{
	
	public static void main(String[] args) {
		while (true) {
			System.out.println("请输入X的值：");
			Scanner sc = new Scanner(System.in);
			String str1 = sc.nextLine();
			
			System.out.println("请输入运算符：");
			String str2 = sc.nextLine();
			
			System.out.println("请输入Y的值：");
			String str3 = sc.nextLine();
			
			Jisuanqi ji = new Jisuanqi();
			Calculator ca = ji;
			//正则表达
			boolean Xresult=str1.matches("^[0-9]*$");
			boolean Markresult=str2.matches("/^\\d+(\\.*\\d{0,2})([+*/-]\\d+(\\.*\\d{0,2}))+$/");
			boolean yresult=str3.matches("^[0-9]*$");
			
			//判断
			if(Xresult==false|| yresult==false) {
				System.out.println("X或者Y的值输入错误！请重新输入");
			}else if(Xresult==true && Markresult==true && yresult==true) {
				ca.panduan(str1,str2,str3);
			}else{
				System.out.println("输入错误！请重新输入");
			}
			System.out.println("输入exit退出");
			String str4 = sc.nextLine();
			if(str4.equals("exit")||str4.equals("EXIT")) {
				System.out.println("退出成功！");
				break;
			}
		}
		
	}
	
}
